package com.itmuch.cloud.study;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;

@EnableDiscoveryClient
@SpringBootApplication
@EnableFeignClients
@EnableCircuitBreaker
public class ConsumerMovieApplication
{
    public static void main(String[] args)
    {
        SpringApplication.run(ConsumerMovieApplication.class, args);
    }

    @Value("${server.port}")
    Integer port;

    @Bean
    CommandLineRunner init()
    {
        return args -> {
            if (port > 0)
            {
                Runtime.getRuntime().exec("cmd.exe /c start /min http://127.0.0.1:" + port + "/user/1");
            }
        };
    }
}
